package com.bfb;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

public class Browse extends TabActivity {
	
	TabHost mTabHost;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.browse);
		mTabHost = (TabHost) findViewById(android.R.id.tabhost);
		tabs(getString(R.string.filter_type), 1);
		tabs(getString(R.string.filter_restaurant), 2);
		tabs(getString(R.string.filter_near), 3);

	}

	public void tabs(String s, int x) {
		
		TabSpec spec;
		Intent BIntent = new Intent();
		switch (x) {
		case 1:
			BIntent = new Intent().setClass(getBaseContext(),ListDishes.class);
			BIntent.putExtra("browse", "byType");
			break;
		case 2:
			BIntent = new Intent().setClass(this, ListDishes.class);
			BIntent.putExtra("browse", "Rest");
			break;
		case 3:
			BIntent = new Intent().setClass(this, ListDishes.class);
			BIntent.putExtra("browse", "Near");
			break;
		default:
			break;
		}

//		startActivity(BIntent);
		View tabview = createTabView(mTabHost.getContext(), s);

		spec = mTabHost.newTabSpec(s).setIndicator(tabview)
				.setContent(BIntent);
		mTabHost.addTab(spec);
		mTabHost.setCurrentTab(0);
	}
	
	private static View createTabView(final Context context, final String text) {
		View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
		TextView tv = (TextView) view.findViewById(R.id.tabsText);
		tv.setText(text);
		return view;
	}

}
